import React, { Component } from 'react'
import './Father.css'
import Son1 from '../Son/Son1'
import Son2 from '../Son/Son2'
export default class Father extends Component {
    state = {
        count: 10,
        age: 10,
    }
    changeAge = (age) => {
        console.log("🚀 ~ Father ~ changeAge ~ age:", age)
        this.setState({
            age: age // 使用传入的age参数来更新父组件的age状态
        })

    }
    changeCount = (count) => {
        console.log("🚀 ~ Father ~ count:", count)
        this.setState({
            count: count // 使用传入的age参数来更新父组件的age状态
        })

    }
    render() {
        return (
            <div className='fatherBox'>
                <h1>父组件</h1>
                <div>age:{this.state.age}</div>
                <div>count:{this.state.count}</div>
                <Son1 count={this.state.count} msg={'花花'} changeAge={this.changeAge}></Son1>
                <Son2 count={this.state.count} msg={12} name={'没有报错'} changeCount={this.changeCount}></Son2>
            </div >
        )
    }
}
